<!doctype html>
<html>
<head>
    <meta charset="utf-8" lang="zh-CN">
    <title>房来房往</title>
    <link href="../../vendors/iview/css/iview.css" rel="stylesheet"/>
    <link href="../../styles/login.css" rel="stylesheet"/>
</head>

<body>
<div class="login_box">
    <div id="biglogin">
        <div class="box_login">
            <div class="banner_box">
                <Carousel autoplay v-model="value2" arrow="never" autoplay-speed="4000">
                    <Carousel-item>
                        <div class="demo-carousel"><img src="../../images/房源信息集中.png"></div>
                    </Carousel-item>
                    <Carousel-item>
                        <div class="demo-carousel" style="margin-left:80px"><img src="../../images/精准房客资源.png"></div>
                    </Carousel-item>
                    <Carousel-item>
                        <div class="demo-carousel" style="margin-left:50px"><img src="../../images/社交式管理.png"></div>
                    </Carousel-item>
                    <Carousel-item>
                        <div class="demo-carousel"><img src="../../images/需求精准化.png"></div>
                    </Carousel-item>
                </Carousel>
            </div>
            <div class="login">
                <div class="logo_img"></div>
                <div class="logo_suru">
                    <form id="fmLogin" name="f" method="post">
                        <div class="dlk_xs">
                            <div class="login_yc">
                                <div class="input_outer">
                                    <span class="u_user"></span>
                                    <input v-model="username" v-validate="'required'" data-vv-as="账号" autocomplete="on"
                                           name="UserName"
                                           class="text_suru"
                                           placeholder="用户名/邮箱/手机号"
                                           style="color: #999 !important" type="text_suru">
                                    <p class="error-tip" v-show="errors.has('UserName')">{{ errors.first('UserName')
                                        }}</p>
                                </div>
                                <div class="input_outer">
                                    <span class="us_uer"></span>
                                    <input v-model="password" v-validate="'required|notCN'" data-vv-as="密码"
                                           name="Password"
                                           class="text_suru"
                                           style="color: #999 !important; position:absolute; z-index:100;"
                                           placeholder="输入密码"
                                           type="password">
                                    <p class="error-tip" v-show="errors.has('Password')">{{ errors.first('Password')
                                        }}</p>
                                </div>
                                <p id="divErrMsg" style="color: #FC4654;text-align: center"></p>
                                <div class="checkbox_box">
                                    <Checkbox on-change="true"><span>记住我</span></Checkbox>
                                </div>
                                <div class="login-fgetpwd_box">
                                    <a href="#" class="login-fgetpwd">忘记密码</a>
                                </div>
                                <div class="mb2">
                                    <i-button :loading="loading" @click="toLoading" class="act-but submit">
                                        <span v-if="!loading">登录</span>
                                        <span v-else>登录中</span>
                                    </i-button>
                                </div>
                            </div>
                        </div>
                        <div class="jszc_box">
                            <a href="#">技术支持？</a>
                        </div>

                    </form>
                </div>
                <div class="ewm_xtb"></div>
                <div class="pc_img"></div>
                <div class="aqdl_box">
                    <div class="saomiao_ewm"></div>
                    <span>微信扫码安全登录</span>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="../../vendors/vue/vue.js"></script>
<script src="../../vendors/iview/js/iview.js"></script>
<script src="../../vendors/es6-promise/es6-promise.min.js"></script>
<script src="../../vendors/es6-promise/es6-promise.auto.min.js"></script>
<script src="../../vendors/jquery.js"></script>
<script src="../../vendors/jquery.form.min.js"></script>
<script src="../../vendors/crypto-js.js"></script>
<script src="../../api/api-config.js"></script>
<script src="../../vendors/vee-validate/vee-validate.min.js"></script>
<script src="../../vendors/vee-validate/locale/zh_CN.js"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha256.js"></script>-->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64.js"></script>-->

<script>
  var validateConfig = {
    locale: 'zh_CN'
  };
  Vue.use(VeeValidate, validateConfig);
  VeeValidate.Validator.extend('notCN', {
    getMessage: function (field, args) {
      return field + ' 不能包含中文';
    },
    validate: function (value, args) {
      return /[^\u4e00-\u9fa5]+/.test(value);
    }
  });

  new Vue({
    el: '#biglogin',
    data: {
      value2: 0,
      loading: false,
      username: '',
      password: ''
    },
    methods: {
      toLoading: function () {
        var that = this
        this.$validator.validateAll({UserName: this.username, Password: this.password}).then(function (result) {
          if (result) {
            // 进入loading状态
            this.loading = true
              window.api.PostLogin({UserName:that.username,Password:that.password})
                .done(function (result) {
                  if (result.IsSuccess) {
                    localStorage.userId = result.ResultObject.UserId;
                    localStorage.companyId = result.ResultObject.CompanyId;
                    localStorage['SecurityManager.key']=result.ResultObject.apiKey;
                    localStorage['SecurityManager.Secret']=result.ResultObject.apiSecret;
                    //window.api.Post_Recovered_Customer({remark:"",customerIdList:["1","2"],isClearVisit:false}).done();
                    //window.location.href = "/";

                    localStorage.userName = result.ResultObject.UserName;
                    window.location.replace(window.location.origin+'/');
                  }
                  else {
                    //alert("Error;" + result.ErrMsg);
                      $("#divErrMsg").html(result.ErrMsg);
                  }
                  that.loading = false
                }).fail(function(res){
                  $("#divErrMsg").html(res.responseJSON.ErrMsg);

              })
          }
        })

      }
    }
  })


</script>
<script>
  $(".aqdl_box,.pc_img").hide();
  $(".ewm_xtb").click(function () {
    $(".aqdl_box,.pc_img").fadeIn()
  });
  $(".ewm_xtb").click(function () {
    $(".login_yc,.ewm_xtb").hide()
  });
  $(".pc_img").click(function () {
    $(".login_yc,.ewm_xtb").fadeIn()
  });
  $(".pc_img").click(function () {
    $(".aqdl_box,.pc_img").hide()
  })
</script>


</body>
</html>
